from django.conf.urls import patterns, include, url
from rest_framework.urlpatterns import format_suffix_patterns
from django.contrib.auth.views import logout
from views import *

urlpatterns = patterns('',
    (r'^$', list_book),
    (r'^search/$', search),
    (r'^book/view/(?P<id>[^/]+)/$', view_book),
    (r'^cart/view/$', view_cart),
    (r'^cart/add/(?P<id>\d+)/$', add_to_cart),
    (r'^cart/clean/$', clean_cart),
    (r'^order/create/$', create_order),
    url(r'^account/login/$', 'django.contrib.auth.views.login', {'template_name': 'bookstoreapp/login.html'}),
    (r'^account/logout/$', logout),
    (r'^account/create/$', create_account),
    url(r'^api/cart/items/$', LineItemList.as_view(), name='line_item-list'),
)

urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'api'])

urlpatterns += patterns('',
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
)
